home *** CD-ROM | disk | FTP | other *** search
- From: kanze@gabi-soft.fr (J. Kanze)
- Message-ID: <KANZE.96Mar4120116@gabi.gabi-soft.fr>
- X-Original-Date: 04 Mar 1996 11:01:16 GMT
- Path: in2.uu.net!bounce-back
- Date: 04 Mar 96 12:49:41 GMT
- Approved: fjh@cs.mu.oz.au
- Newsgroups: comp.std.c++
- Subject: Re: wchar_t version of atof() and atoi()?
- Organization: GABI Software, Sarl.
- References: <4h4oiv$4md@xanadu.io.com>
- In-Reply-To: jamshid@io.com's message of 29 Feb 1996 10:49:07 PST
- X-Auth: PGPMoose V1.1 PGP comp.std.c++
- iQBFAgUBMTrm/uEDnX0m9pzZAQGxMgGAhYsWkXGc2VQtsQSbLaAjzlTiulfhsEfr
- TiJHnfDrFTkGC5A6aAZoBctvqsl+mXtZ
- =uCBn
-
- In article <4h4oiv$4md@xanadu.io.com> jamshid@io.com (Jamshid Afshar)
- writes:
-
- |> I'm new to internationalization issues but it's my understanding that
- |> Standard C++ will have very good support for it by way of the
- |> wide-character wstring and wifstream, etc. classes. For example, a
- |> C++ program written in an environment that supports Unicode would
- |> strictly use wstring, wifstream, and wchar_t in place of string,
- |> ifstream, and char [1]. But, I didn't see a wchar_t* overload of
- |> functions like strtod() or atoi(). How are strings (eg, entered by a
- |> user into an edit box) supposed to be converted to numeric values in
- |> an internationalized C++ program?
-
- Using a wchar_t version of istringstream, I suppose. In general, very
- little has been done with regards to the various functions inherited
- from C that operated on char* or const char*; it is expected that most
- C++ programs will use string and iostream.
-
- |> I would do something like:
-
- |> int atoi( const wstring& s ) {
- |> wistringstream strm(s);
- |> int r;
-
- ===> s.setf( ios::dec , ios::basefield) ;
-
- |> s >> r;
- |> if (s) return r;
- |> else throw some_exception();
- |> }
-
- |> But stream i/o interprets "045" as an octal value instead of 45.
-
- Insert the specified line. On creation, the basefield is 0, which has
- the behavior you describe.
-
- --
- James Kanze (+33) 88 14 49 00 email: kanze@gabi-soft.fr
- GABI Software, Sarl., 8 rue des Francs Bourgeois, 67000 Strasbourg, France
- Conseils, itudes et rialisations en logiciel orienti objet --
- -- A la recherche d'une activiti dans une region francophone
- ---
- [ To submit articles: try just posting with your news-reader.
- If that fails, use mailto:std-c++@ncar.ucar.edu
- FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html
- Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
- Comments? mailto:std-c++-request@ncar.ucar.edu.
- ]
-